home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / DIBLK.PAK / MAINFRM.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  134 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "diblook.h"
  15.  
  16. #include "mainfrm.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMainFrame
  25.  
  26. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  29.     //{{AFX_MSG_MAP(CMainFrame)
  30.     ON_WM_CREATE()
  31.     ON_WM_PALETTECHANGED()
  32.     ON_WM_QUERYNEWPALETTE()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // arrays of IDs used to initialize control bars
  38.  
  39. // toolbar buttons - IDs are command buttons
  40. static UINT BASED_CODE buttons[] =
  41. {
  42.     // same order as in the bitmap 'toolbar.bmp'
  43.     ID_FILE_NEW,
  44.     ID_FILE_OPEN,
  45.     ID_FILE_SAVE,
  46.         ID_SEPARATOR,
  47.     ID_EDIT_CUT,
  48.     ID_EDIT_COPY,
  49.     ID_EDIT_PASTE,
  50.         ID_SEPARATOR,
  51.     ID_FILE_PRINT,
  52.     ID_APP_ABOUT,
  53. };
  54.  
  55. static UINT BASED_CODE indicators[] =
  56. {
  57.     ID_SEPARATOR,           // status line indicator
  58.     ID_INDICATOR_CAPS,
  59.     ID_INDICATOR_NUM,
  60.     ID_INDICATOR_SCRL,
  61. };
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CMainFrame construction/destruction
  65.  
  66. CMainFrame::CMainFrame()
  67. {
  68. }
  69.  
  70. CMainFrame::~CMainFrame()
  71. {
  72. }
  73.  
  74. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  75. {
  76.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  77.         return -1;
  78.  
  79.     if (!m_wndToolBar.Create(this) ||
  80.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  81.         !m_wndToolBar.SetButtons(buttons,
  82.           sizeof(buttons)/sizeof(UINT)))
  83.     {
  84.         TRACE0("Failed to create toolbar\n");
  85.         return -1;      // fail to create
  86.     }
  87.  
  88.     if (!m_wndStatusBar.Create(this) ||
  89.         !m_wndStatusBar.SetIndicators(indicators,
  90.           sizeof(indicators)/sizeof(UINT)))
  91.     {
  92.         TRACE0("Failed to create status bar\n");
  93.         return -1;      // fail to create
  94.     }
  95.  
  96.     return 0;
  97. }
  98.  
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CMainFrame commands
  102.  
  103.  
  104. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd)
  105. {
  106.     CMDIFrameWnd::OnPaletteChanged(pFocusWnd);
  107.  
  108.     // always realize the palette for the active view
  109.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  110.     if (pMDIChildWnd == NULL)
  111.         return; // no active MDI child frame
  112.     CView* pView = pMDIChildWnd->GetActiveView();
  113.     ASSERT(pView != NULL);
  114.  
  115.     // notify all child windows that the palette has changed
  116.     SendMessageToDescendants(WM_DOREALIZE, (WPARAM)pView->m_hWnd);
  117. }
  118.  
  119.  
  120.  
  121. BOOL CMainFrame::OnQueryNewPalette()
  122. {
  123.     // always realize the palette for the active view
  124.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  125.     if (pMDIChildWnd == NULL)
  126.         return FALSE; // no active MDI child frame (no new palette)
  127.     CView* pView = pMDIChildWnd->GetActiveView();
  128.     ASSERT(pView != NULL);
  129.  
  130.     // just notify the target view
  131.     pView->SendMessage(WM_DOREALIZE, (WPARAM)pView->m_hWnd);
  132.     return TRUE;
  133. }
  134.